#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_map>

using namespace std;
const int N = 1e5 + 10;

int n;
string q[N];



int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    int T;
    cin >> T;

    while(T--){
        cin >> n;
        unordered_map<string, bool, hash_pair> mp;
        for (int i = 0; i < n; i ++){
            cin >> q[i];
        }

        for (int i = 0; i < n; i ++){
            mp[q[i]] = true;
        }

        for (int i = 0; i < n; i ++){
            bool flag = false;
            for (int j = 0; j < q[i].length(); j ++){
                if(mp[q[i].substr(0, j)] && mp[q[i].substr(j, q[i].length())]){
                    flag = true;
                    break;
                }
            }

            if(flag){
                printf("1");
            }else{
                printf("0");
            }
        }

        printf("\n");
    }

    return 0;
}